home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17019 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: wabbit.its.uow.edu.au!not-for-mail
  2. From: sjl01@wumpus.its.uow.edu.au (Stuart John Langley)
  3. Newsgroups: comp.lang.c++
  4. Subject: Help: Bitwise operators
  5. Date: 13 Apr 1996 14:40:03 +1000
  6. Organization: University of Wollongong, NSW, Australia.
  7. Message-ID: <4knb73$f15@wumpus.its.uow.edu.au>
  8. NNTP-Posting-Host: wumpus.its.uow.edu.au
  9. X-Newsreader: NN version 6.5.0 #5
  10.  
  11. Hi All,
  12.  
  13. I need some help understanding some code that i need to translate.
  14. I have the following,
  15.  
  16. unsigned char byte;
  17.  
  18. then either - 
  19.  
  20. byte = (byte >> 1) | 0;
  21.  
  22. or 
  23.  
  24. byte = (byte >> 1) | 128;
  25.  
  26. I know that the first case places a 0 in the left most bit of byte,
  27. and moves everything else to the right, while the second places a 1
  28. in the leftmost bit. However, when I look at the texts and hepfiles,
  29. this seems to indicate thet the 0 or 1 should be placed in the rightmost
  30. bit and everything else moved left. Can somebody please help me out with
  31. this problem>
  32.  
  33. Thanks,
  34.  
  35. Stuart
  36.  
  37. -- 
  38. --
  39. sjl01@uow.edu.au    | "Despite all my rage, I'm still just
  40. Stuart Langley        |  a rat in a cage."
  41. Wollongong, Australia    |            - SP
  42.